1. Field of the Invention
The present invention relates to a memory system and a method of writing into a memory using a card controller, for example.
2. Description of the Related Art
A memory card having a nonvolatile semiconductor memory such as a flash memory is used as a medium for recording music data or video data. A typical example of a flash memory for use in a memory card includes a NAND type flash memory.
Data in a memory is managed in accordance with a write request from an application, etc., by a file system in a host device into which a memory card is inserted. The file system divides a file to be written into cluster sized pieces of data. The divided data each are assigned with a logical address, and the data are assigned to unassigned clusters in the order of a logical address. The memory card writes the data in the memory while managing the correspondence between a logical address of each data and a physical address for writing the data of the logical address on a table or the like realized on the memory.
When a file system of this type is used, management data such as FAT and information on a root directory entry as well as the written data are required to be updated upon writing of the data in the memory. The NAND type flash memory, however, has the features that (1) data is written page by page, (2) data is erased for each block which consists of a plurality of pages, and (3) the data cannot be written in a page which already holds data. For updating data by page, therefore, the process described below is executed by using an erased block. Specifically, data to be updated (new data) is written into a new block into which no data is written, and then, the remaining data not updated are copied to the new block from an old block containing old data (data to be rewritten into the new data). As a result, a considerable time may be required to update the data of each page.
As described above, the management data is updated frequently as the need arises each time of writing a file. For this reason, in the memory card using both the flash memory and the FAT file system, the data write or rewrite speed may be slow.
In order to avoid the reduction in write speed, management data of FAT file system may be written into a cache block (subblock) dedicated for storing data from lower address page to higher address page in the order of write request. The cache block is provided in addition to a block (original block) into which data of each logical address is to be originally written. With the arrival of a request to write given data, the data is written in the original block. Each time a request to update data already written in the original block arrives, the data is sequentially written in the subblock. In the process, the memory card prepares a correspondence table indicating into which page of the subblock the latest data of a given logical address is written.
The card reconstructs the original block at a predetermined timing. The reconstruction involves collecting the latest data of each logical address in the subblock into the original block with reference to the correspondence table.
However, the reconstruction of an original block poses the problem described below. Assume, for example, that a block B1 is an original block for storing data of addresses 0 to 5, as shown in FIG. 16. Each old data of addresses 0 to 5 is stored in the block B1, and each latest data of addresses 0 to 5 are stored in a subblock SB for the original block B1. When the original block for addresses 0 to 5 is reconstructed from this state, the following procedures are taken. First, an erased block B2 is prepared, and the latest data of address 0 is read from page 5 of the subblock and written into page 1 of the block B2.
Next, the latest data of address 1 is read from page 4 of the subblock, and written into page 2 of the block B2. By repeating this job, the latest data of addresses 0 to 5 are written into the block B2, as shown in FIG. 16. Finally, the block B2 is set as a corresponding original block for addresses 0 to 5.
For the purpose of executing the above-described process, the read and write processes are repeatedly executed as many times as the addresses assigned to one original block (six addresses in the shown example). During the reconstruction, the memory card continues to output a busy signal to the host device. If the busy signal is output for longer than the period of time set in the host device, the host device may determine that the memory card is in trouble. This problem becomes more conspicuous with the increase in page capacity due to the technological progress.